#include <iostream>
#define MAXN 360
using namespace std;
int angle[MAXN][MAXN];
int dp[MAXN][MAXN];
int N;

void solve();
int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= i; j++) {
            cin >> angle[i][j];
        }
    }
    solve();
}

void solve() {
    dp[1][1] = angle[1][1];
    for (int i = 2; i <= N; i++) {
        for (int j = 1; j <= i; j++) {
            if (j == 1) dp[i][j] = dp[i - 1][j] + angle[i][j];
            else if (j == i) dp[i][j] = dp[i - 1][j - 1] + angle[i][j];
            else dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j]) + angle[i][j];
        }
    }
    int res = 0;
    for (int i = 1; i <= N; i++) {
        res = max(dp[N][i], res);
    }
    cout << res << endl;
}